//
//  DanPinCollectionViewCell.m
//  PhoenixNews
//
//  Created by dllo on 16/1/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "DanPinCollectionViewCell.h"

@implementation DanPinCollectionViewCell
- (void)dealloc {
    [_price release];
    [_name release];
    [_imageView release];
    [_likes release];
    [_imageLikes release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        self.imageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageView];
        [_imageView release];
        self.name = [[UILabel alloc] init];
        [self.contentView addSubview:_name];
        [_name release];
        
        self.price = [[UILabel alloc] init];
        [self.contentView addSubview:_price];
        [_price release];
        
        self.imageLikes = [[UIImageView alloc] init];
        [self.contentView addSubview:_imageLikes];
        [_imageLikes release];
        
        self.likes = [[UILabel alloc] init];
        [self.contentView addSubview:_likes];
        [_likes release];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _imageView.frame = CGRectMake(0, 0, layoutAttributes.size.width , layoutAttributes.size.height - 90 );
    _name.frame = CGRectMake(10, _imageView.frame.size.height + 5, _imageView.frame.size.width, 60);
    _name.numberOfLines = 0;
    
    _price.frame = CGRectMake(10, self.name.frame.origin.y + 50, 70, 40);
    _price.textColor = [UIColor redColor];
    
    _likes.frame = CGRectMake(self.price.frame.origin.x + 70, self.price.frame.origin.y, 60, 40);
}

@end
